<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>应收账款统计</title>
        <% include("/common/common_css_js.html"){} %>
    </head>
    <body>
        <div style="padding-bottom: 5px;">
            <div id="queryForm" class="uc-toolbaroverflow" _borderStyle="border-top:0;">

                <span>业务员:</span>
                <div id="keyDeliveryCustomerSalemanId" name="keyDeliveryCustomerSalemanId" class="mini-autocomplete" style="width:150px;"  popupWidth="500" textField="name" valueField="id"
                     required="false" requiredErrorText="业务员不能为空"
                     url="${base}/pages/customer_manage/queryDeliveryCustomerSalesmanByKey"
                     searchField="key"
                     emptyText="业务员姓名或电话">
                    <div property="columns">
                        <div header="姓名" field="name" width="150"></div>
                        <div header="电话" field="mobile" width="150"></div>
                    </div>
                </div>


                <span class="separator"></span>
                <span>发货人:</span>
                <div id="keyDeliveryCustomerId" name="keyDeliveryCustomerId" class="mini-autocomplete" style="width:250px;"  popupWidth="1000" textField="name" valueField="id"
                     url="${base}/pages/customer_manage/queryDeliveryCustomerByKey"  required="false" requiredErrorText="发货人不能为空"
                     searchField="key"
                     emptyText="发货人名称">
                    <div property="columns">
                        <div header="ID" field="id" width="30"></div>
                        <div header="客户名称" field="name"></div>
                        <div header="客户简称" field="shortName"></div>
                        <div header="客户电话" field="phone"></div>
                        <div header="客户地址" field="address"></div>
                    </div>
                </div>


                <span class="separator"></span>
                <span>分单归属部门:</span>
                <input id="keyAttributionDepartmentId" name="keyAttributionDepartmentId" class="mini-treeselect" style="width:250px;" textField="name" valueField="id" emptyText="请选择..."
                       virtualScroll="true" expandOnLoad="2"   required="false" allowInput="true" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择开单部门"/>

                <div id="keyCk1" name="keyCk1" class="mini-checkbox" readOnly="false" text="包含子部门"></div>

                <span class="separator"></span>
                <span>开单日期：</span>
                <input id="keyOpenBillStartDate" name="keyOpenBillStartDate"  class="mini-datepicker"   format="yyyy-MM-dd"/>--<input id="keyOpenBillEndDate" name="keyOpenBillEndDate" class="mini-datepicker"  format="yyyy-MM-dd"/>

                <div style="margin-top: 5px"></div>

                <% if(so.hasPermission("customerReceivables:query")){%>
                    <a class="mini-button" iconCls="icon-search" onclick="searchBill()">查询</a>
                <% } %>

                <% if(so.hasPermission("customerReceivables:queryCndClear")){%>
                    <a class="mini-button" iconCls="icon-new" onclick="clearSearch()">清空查询条件</a>
                <% } %>

                <span class="separator"></span>

                <% if(so.hasPermission("customerReceivables:download")){%>
                    <#download_grid id="downloadGrid" theGridId="datagrid1" theFileName="应收账款统计表"/>
                <% } %>
            </div>
        </div>

        <div class = "mini-fit">
            <div id="datagrid1" class="mini-datagrid"
                 style="width: 100%; height: 100%;"
                 url="${base}/pages/finance_manage/statistics/queryReceivablesStatisticsList" idField="id"
                 showPager="true" pageSize="20" sizeList="[10,20,30,50,100]"
                 multiSelect = "true" allowResize="true"
                 showGroupsSummary="true" showSummaryRow="true" summaryPosition="bottom"
                 allowSortColumn = "true"

                 ondrawsummarycell="summaryRight"
            >
                <div property="columns">
                    <div field="attributionDepartmentId" width="140" headerAlign="center" align="center" allowSort="false" data-options='{cacheName:"department"}' renderer="commonRender">归属部门</div>
                    <div field="deliveryCustomerName" width="140" headerAlign="center" align="center" allowSort="false" >发货人</div>
                    <div field="openBillMonth" width="140" headerAlign="center" align="center" allowSort="false" >开单月份</div>
                    <div field="totalBill" width="140" headerAlign="center" align="right" allowSort="false" summaryType="sum">总单数</div>
                    <div field="totalNumber" width="140" headerAlign="center" align="right" allowSort="false" summaryType="sum">总件数</div>
                    <div field="totalSettlementAmount" width="140" headerAlign="center" align="right" allowSort="false" summaryType="sum"><span style="color: red">总待结算金额</span></div>
                    <div field="totalDropAmount" width="140" headerAlign="center" align="right" allowSort="false" summaryType="sum">总拉货金额</div>

                    <div field="totalActualWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总实际重量</div>
                    <div field="totalChargeableWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总计费重量</div>
                    <div field="totalVolume" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总体积</div>
                    <div field="totalTransportCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总运费</div>

                    <div field="totalInsuranceFee" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总保费</div>
                    <div field="totalOpenBillDeliveryCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总开单送货费</div>
                    <div field="totalAgentDeliveryCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总代理送货费</div>
                    <div field="totalTax" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总税金</div>

                    <div field="totalFuelSurcharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总燃油费</div>
                    <div field="totalCollectionMoney" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总代收款</div>
                    <div field="totalOtherCharges" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总其他费用</div>
                    <div field="totalServiceCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总业务费</div>


                    <div field="totalActualTransportCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总实收运费</div>
                    <div field="totalDeliveryCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总发货客户付款</div>
                    <div field="totalReceiveCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总收货客户付款</div>
                    <div field="totalAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总金额</div>

                    <div field="totalActualAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总实收金额</div>
                    <div field="totalShareCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总分摊成本</div>
                    <div field="totalOperatingCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总操作费</div>
                    <div field="totalGrossProfit" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总毛利润</div>

                </div>
            </div>
        </div>

        <script type="text/javascript">
            mini.parse();

            let keyDeliveryCustomerSalemanId = mini.get("keyDeliveryCustomerSalemanId");
            let keyDeliveryCustomerId = mini.get("keyDeliveryCustomerId");
            let keyAttributionDepartmentId = mini.get("keyAttributionDepartmentId");

            let keyOpenBillStartDate = mini.get("keyOpenBillStartDate");
            let keyOpenBillEndDate = mini.get("keyOpenBillEndDate");

            let grid = mini.get("datagrid1");

            $(function () {

                // 部门下拉列表
                let keyAttributionDepartmentIdJsonData = commonRenderDropList("department");
                keyAttributionDepartmentId.loadList(keyAttributionDepartmentIdJsonData,"id","pid");

                // 加载列表数据
                grid.load();
            });

            /**
             * 清空查询条件
             */
            function clearSearch(){
                let form = new mini.Form("#queryForm");
                form.clear();
            }

            /**
             * 根据查询条件查询分单
             */
            function searchBill(){
                let form = new mini.Form("#queryForm");
                let data = form.getData(true);
                grid.load(data);
            }

            /**
             * 设置底部统计样式
             * @param e
             */
            function summaryRight(e){
                e.cellStyle="text-align:right;color:red;font-size:18px;font-weight:bold";
            }
        </script>
    </body>
</html>